<?php 
class NodeController extends Controller{
	public $db;
	public function __init(){
		$this->db=K('Node');
	}

	public function index(){
		$Node=$this->db->all();
		$this->assign('node',$Node);
		$this->display();
	}
	//添加
	public function add(){
		if(IS_POST){
			if($this->db->addNode()){
				$this->success('角色添加成功','index');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display();
		}
	}

	//编辑
	public function edit(){
		if(IS_POST){
			if($this->db->editNode()){
				$this->success('编辑成功','index');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$nid=Q('nid',0,'intval');
			$field=$this->db->find($nid);
			$this->assign('field',$field);
			$this->display();
		}
	}

	//删除
	public function del(){
		if($this->db->delRole()){
			$this->success('节点删除成功','index');
		}else{
			$this->error($this->db->error);
		}
	}



}

?>